package com.aigou.admin.service.impl;

import com.aigou.admin.dao.OrderDAO;
import com.aigou.admin.dao.impl.OrderDAOImpl;
import com.aigou.admin.entity.Order;
import com.aigou.admin.entity.PageEntity;
import com.aigou.admin.service.Orderservice;

import java.util.List;

public class OrderserviceImpl implements Orderservice {

    private OrderDAO orderDAO = new OrderDAOImpl();

    @Override
    public PageEntity<Order> findOrderPage(Integer current, Integer pageSize) {
        int total = orderDAO.selectorderCount();
        List<Order> orders = orderDAO.orderLimit((current - 1) * pageSize,pageSize);
        PageEntity<Order> pageEntity = new PageEntity<>();
        pageEntity.setCurrent(current);
        pageEntity.setPageSize(pageSize);
        pageEntity.setTotal(total);
        pageEntity.setRecords(orders);
        return pageEntity;
    }

    @Override
    public List<Order> findAll() {
        return orderDAO.setAll();
    }

    @Override
    public Order findByid(String id) {
        return orderDAO.selectById(id);
    }

    @Override
    public boolean save(Order order) {
        return orderDAO.inser(order);
    }

    @Override
    public boolean delete(String id) {
        return orderDAO.delete(id);
    }

    @Override
    public boolean update(Order order) {
        return orderDAO.update(order);
    }

}
